import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import VueQuillEditor from "vue-quill-editor"
import 'quill/dist/quill.core.css' // import styles
import 'quill/dist/quill.snow.css' // for snow theme
import 'quill/dist/quill.bubble.css' // for bubble theme
Vue.config.productionTip = false
Vue.use(ElementUI)
Vue.use(VueQuillEditor)
router.beforeEach((to,from,next)=>{
  console.log(to)
  if(to.path !== '/home'){
    store.dispatch('setTitleObj',to.meta)
  }else{
    store.dispatch('setShowBread',false)
    store.dispatch('setDefIndex','/home')
  }
  if(to.path !== '/login'){
    if(window.sessionStorage.getItem('token')){
      next()
    }else{
      next('/login')
    }
  }else{
    next()
  }
})

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
